﻿
(function($) {
    var worker = undefined;
    $.NoticeSender = {
        init: function(userid, username, isPlateform) {
            worker = $.connection.noticeHub;
            worker.client.showNotice = function(title, content) {
                console.log('收到新通知');
                var _type = title.split('|')[0];
                var _title = title.split('|')[1];
                console.log('通知类型[' + _type + '],标题[' + _title + ']');
                top.Lobibox.notify(_type,
                {
                    width: 250,
                    delay: false,
                    title: _title,
                    msg: content
                });
            };
            $.connection.hub.start().done(function() {
                worker.server.sendLogin(userid, username, isPlateform);
                console.log('SignalR连接成功.');
            });
        },
        sendToSupplier: function(title, msg, supplierId) {
            worker.server.sendNotice(title, msg, supplierId);
            console.log('平台通知供货商');
        },
        sendToPlateform: function(title, msg) {
            worker.server.sendToPlateform(title, msg);
            console.log('供货商通知平台');
        }
    };
})(jQuery);